<!--   [PAGE]] : 银行信息
       @Author  : ljq
       @Created : 2025/10/4
 -->
<template>
  <div class="app-container">
    <!-- ------------------------ START: 查询框 -------------------------->
    <el-form class='query' :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="银行编码">
        <el-input v-model="queryParams.params.bankCodeLike" placeholder="请输入银行编码" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="银行名称">
        <el-input v-model="queryParams.params.bankNameLike" placeholder="请输入银行名称" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="状态">
        <el-select v-model="queryParams.status" placeholder="状态" clearable>
          <el-option v-for="dict in dict.type.status" :key="dict.value" :label="dict.label" :value="dict.value"/>
        </el-select>
      </el-form-item>

      <el-form-item class="option">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- ------------------------- END: 查询框 --------------------------->

    <!-- ---------------------- START: 主数据区域------------------------->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['business:bank:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['business:bank:remove']">批量删除</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"/>
    </el-row>


    <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="50" align="center"/>
      <el-table-column label="编号" align="center" prop="id" v-if="columns[0].visible"/>
      <el-table-column label="图标" align="center" prop="bankLogo" v-if="columns[4].visible"/>
      <el-table-column label="银行编码" align="center" prop="bankCode" v-if="columns[1].visible"/>
      <el-table-column label="银行名称" align="center" prop="bankName" v-if="columns[2].visible"/>
      <el-table-column label="银行简称" align="center" prop="bankShortName" v-if="columns[3].visible"/>
      <el-table-column label="客服电话" align="center" prop="customerServicePhone" v-if="columns[5].visible"/>
      <el-table-column label="官方网站" align="center" prop="website" v-if="columns[6].visible"/>
      <el-table-column label="状态" align="center" prop="status" v-if="columns[7].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[8].visible"/>
      <el-table-column label="创建者" align="center" prop="createBy" v-if="columns[9].visible"/>
      <el-table-column label="更新时间" align="center" prop="updateTime" v-if="columns[10].visible"/>
      <el-table-column label="更新者" align="center" prop="updateBy" v-if="columns[11].visible"/>
      <!-- 操作列组件 -->
      <operation-column :permi="permi" @edit="handleUpdate" @delete="handleDelete"/>

    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>
    <!-- ---------------------- END: 主数据区域 ------------------------>

    <!-- ------------------------ START: 弹出框 -------------------------->
    <el-dialog :title="title" :visible.sync="open" width="780px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="银行编码" prop="bankCode">
              <el-input v-model="form.bankCode" placeholder="请输入银行编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="银行名称" prop="bankName">
              <el-input v-model="form.bankName" placeholder="请输入银行名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="银行简称" prop="bankShortName">
              <el-input v-model="form.bankShortName" placeholder="请输入银行简称"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="图标" prop="bankLogo">
              <el-input v-model="form.bankLogo" placeholder="请输入图标"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="客服电话" prop="customerServicePhone">
              <el-input v-model="form.customerServicePhone" placeholder="请输入客服电话"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="官方网站" prop="website">
              <el-input v-model="form.website" placeholder="请输入官方网站"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="状态" prop="status">
              <el-select v-model="form.status" placeholder="状态">
                <el-option v-for="dict in dict.type.status" :key="dict.value" :label="dict.label" :value="dict.value"/>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- ------------------------ END: 弹出框 -------------------------->
  </div>

</template>
<script>
import {listBank, getBank, addBank, updateBank, delBank} from "@/api/business/bank";
import {initData, baseMethods} from "@/utils/basePage";

let baseData = initData();
baseData.showSearch = false;

// TODO 测试未通过
baseData.form.status = "1";

export default {
  name: "Bank",
  dicts: ['status'],
  data() {
    return {
      ...baseData,
      permi: 'business:bank',
      // 列信息
      columns: [
        {key: 0, label: `编号`, visible: true},
        {key: 1, label: `银行编码`, visible: true},
        {key: 2, label: `银行名称`, visible: true},
        {key: 3, label: `银行简称`, visible: true},
        {key: 4, label: `图标`, visible: true},
        {key: 5, label: `客服电话`, visible: true},
        {key: 6, label: `官方网站`, visible: true},
        {key: 7, label: `状态`, visible: true},
        {key: 8, label: `创建时间`, visible: true},
        {key: 9, label: `创建者`, visible: false},
        {key: 10, label: `更新时间`, visible: false},
        {key: 11, label: `创建者`, visible: false},
      ],
      // 表单校验
      rules: {
        bankCode: [{required: true, message: "银行编码不能为空", trigger: "blur"}],
        bankName: [{required: true, message: "银行名称不能为空", trigger: "blur"}],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    ...baseMethods(listBank, getBank, addBank, updateBank, delBank),

    handleAdd1() {
      console.log(">>>>>>>> ", this.form);
    }

  }
};
</script>
